package com.yueqian.exception;

import javax.swing.*;
import java.util.Scanner;

public class Test5 {
    public static void main(String[] args) {
        try {
            inputGender();
        } catch (GenderException e) {
            e.printStackTrace();
        }
    }

    private static void inputGender() throws GenderException {
        System.out.println("请输入性别：");
        Scanner sc = new Scanner(System.in);
        String gender = sc.nextLine();

        if ("男".equalsIgnoreCase(gender) ||
                "女".equalsIgnoreCase(gender)) {
            System.out.println("你的性别：" + gender);
        } else {

            throw new GenderException();
        }

    }
}
